﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ShopInTheEvent
{
    public partial class AddNewProduct : Form
    {
        private DataHelper dh;
        public AddNewProduct()
        {
            InitializeComponent();
            dh = new DataHelper();
            
        }

        private void bt_AddTheProduct_Click(object sender, EventArgs e)
        {
            if (tb_ForeCode.Text != "" && tb_ProductName.Text != "" && tb_Price.Text != "" && tb_quantity.Text!="") 
            {
                int nrAdded = dh.AddNewProduct(tb_ForeCode.Text, tb_ProductName.Text, Convert.ToDouble(tb_Price.Text), Convert.ToInt32(tb_quantity.Text));
                if (nrAdded > 0)
                {
                    MessageBox.Show("Succesfully added to the database!");
                }
                else 
                {
                    MessageBox.Show("Error while adding products!");
                }
                 
            }
        }
    }
}
